package kk.dao.impl;

import kk.dao.UserDao;
import kk.domain.User;

public class UserDaoImpl extends BaseDao implements UserDao {

    @Override
    public User queryUserByUsernameAndPassword(String username, String password) {
        String sql = "select * from user where username = ? and password = ? ";
        return queryForOne(User.class, sql, username,password);
    }

    @Override
    public User queryUserByUsername(String username) {
        String sql = "select * from user where username = ?";
        return queryForOne(User.class, sql, username);
    }

    @Override
    public int savaUser(User user) {
        String sql="insert into user values(null,?,?,?)";
        return update(sql, user.getUsername(),user.getPassword(),user.getEmail());
    }
}
